﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;

namespace OMC.Classification
{
    /// <summary>
    /// Class <c>TextClassifierResultItem</c> represents an item from a classification result.
    /// </summary>
    public struct TextClassifierResultItem
    {
        /// <summary>
        /// The class.
        /// </summary>
        public string @Class;

        /// <summary>
        /// The probability.
        /// Invariant: 0.0 &lt; probability &amp;&amp; probability &gt; 1.0
        /// </summary>
        public double Probability;

        /// <summary>
        /// Create a new <c>TextClassifierResultItem</c>.
        /// </summary>
        /// <param name="class">The class an item is classified; not <c>null</c>.</param>
        /// <param name="probability">The probability of the classification; between 0.0 and 1.0.</param>
        public TextClassifierResultItem(string @class, double probability)
        {
            Contract.Requires(@class != null);
            Contract.Requires(0.0 <= probability && probability <= 1.0);

            this.@Class = @class;
            this.Probability = probability;
        }

        /// <summary>
        /// A string representing this result item.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return "Class <" + @Class + "> with probability <" + Probability + ">.";
        }

        //[ContractInvariantMethod]
        //protected void ObjectInvariant () 
        //{
        //    Contract.Invariant(@Class != null);
        //    Contract.Invariant(0.0 <= Probability && Probability <= 1.0);
        //}
    }
}
